using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class JobSeekers_forgotpassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Contents["rcuserid"] != null)
        {
            Response.Redirect("myaccount.aspx");
        }
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            MailProvider mailProvider = new MailProvider();
            SecurityProvider securityProvider = new SecurityProvider();
            RecruitVietnam cls = new RecruitVietnam();
            cls.ConnectionString =
            WebConfigurationManager.ConnectionStrings[
               "RecruitVietnam"].ConnectionString;
             
            string oldPassword = 
            cls.GetPassword(txtEmail.Text, 
            txtCompanyName.Text + 
            " " + txtEnglishName.Text, 
            txtDOE.Text, "1");
            oldPassword = securityProvider.RCVDecPwd(oldPassword);
            if (cls.ErrorMessage == "" && oldPassword != "")
            {
                mailProvider.SendMail(txtEmail.Text,
                "Forgot password", 
                "Here is your RCV password: "
                + oldPassword);
                literalError.Text = 
                "Send RCV password to your email successful.";
                btnOK.PostBackUrl="login.aspx";  
            }
            else
            {
                literalError.Text = 
                "Sorry, can not send RCV password to you. "
                + cls.ErrorMessage;
                 
            }
        }
        catch (Exception ex)
        {
            literalError.Text = ex.Message;
        }
    }
 
    }
